# -- coding: utf-8 --
from application.space_server_api import SpaceServer
from tools.Request_General import BaseAPI
from tools.encryption import get_sha256
from pyLib.databaseManage import ACCOUNT_DATABASE


class UserAccount(BaseAPI):
    """用户账户中心"""

    def login(self, payload):
        """登录"""
        # 加密
        payload['password'] = get_sha256(get_sha256(get_sha256(payload.get('password'))))
        r = self.request_send(json=payload)
        return r

    def email_invitation_space(self, payload):
        """空间-邮件邀请"""
        r = self.request_send(json=payload)
        return r

    def enterprise_space_hierarchy(self):
        """
        查询企业/空间层级
        :return: 如果传空间id的话则返回platformCode,spaceName
        """
        r = self.request_send()
        return r

    def add_group(self, payload, get_group_id=False):
        """新增用户组"""
        r = self.request_send(json=payload)
        if get_group_id:
            group_id = ACCOUNT_DATABASE.execute_sql(
                f"SELECT id FROM user_group WHERE group_name='{payload.get('groupName')}'")[0][0]
            return group_id
        return r

    def remove_group(self, payload):
        """删除用户组"""
        r = self.request_send(json=payload)
        return r

    def invitation_user_join_space(self, payload):
        """已有用户邀请加入空间"""
        r = self.request_send(json=payload)
        return r

    def create_user_join_enterprise_and_space(self, email_list: list, spaceId, enterpriseId):
        """
        创建新的用户并加入到指定企业下
        :param email_list: 邮箱
        :param spaceId: 空间id
        :param enterpriseId: 企业id
        :return:新用户的userId
        """
        # 查询空间参数
        data = SpaceServer(self.headers).get_config_params().json().get("data")
        # 查询空间的platformCode，spaceName
        platformCode = data.get("platformCode")
        spaceName = data.get("spaceName")
        self.email_invitation_space(
            {"enterpriseId": enterpriseId, "emails": email_list, "platformCode": platformCode, "spaceId": spaceId,
             "spaceName": spaceName})
        emails = ','.join(f"'{email}'" for email in email_list)
        # 修改用户状态为可用密码为123并查询用户id
        res = ACCOUNT_DATABASE.execute_sql([
            f"UPDATE user_info SET status=1,password='$2a$10$OIkuuUAQZwwRuqN6mWickuACSeo7dDncb5Ct9RJmEOT7NmkOKPiKW' WHERE email in ({emails})",
            f"SELECT id FROM user_info WHERE email in ({emails})"])
        if len(email_list) == 1:
            return res[0][0]
        else:
            return [user_id for user_id in res]


# account_server = "/system-account-api"
# # 注册接口
# register_url = f"{ACCOUNT_HOST}{account_server}/oauth/register"
# # 发送注册验证码
# register_verification_code_url = f"{ACCOUNT_HOST}{account_server}/oauth/register/verification-code"
# # 登录接口
# login_url = f"{ACCOUNT_HOST}{account_server}/oauth/login"
# # cookie校验
# checkCookie_url = f"{ACCOUNT_HOST}{account_server}/oauth/checkCookie"
# # 登录接口(临时令牌)
# login_ticket_url = f"{ACCOUNT_HOST}{account_server}/oauth/login/ticket"
# # 登出接口
# logout_url = f"{ACCOUNT_HOST}{account_server}/oauth/login/logout"
# # 发送登录验证码
# login_verification_code_url = f"{ACCOUNT_HOST}{account_server}/oauth/login/send/verification-code"
# # 验证码登录
# login_by_code_url = f"{ACCOUNT_HOST}{account_server}/oauth/login/verification-code"
# # 验证码登录(临时令牌)
# ticket_login_by_code_url = f"{ACCOUNT_HOST}{account_server}/oauth/login/ticket/verification-code"
# # 绑定邮箱接口
# bind_email_url = f"{ACCOUNT_HOST}{account_server}/api/user/bind-email"
# # 解绑邮箱接口
# unbind_email_url = f"{ACCOUNT_HOST}{account_server}/api/user/unbind-email"
# # 绑定邮箱发送邮件验证码接口
# email_verification_code_url = f"{ACCOUNT_HOST}{account_server}/api/user/verification-code-email"
# # 解绑邮箱发送邮件验证码接口
# unbind_email_verification_code_url = f"{ACCOUNT_HOST}{account_server}/api/user/unbind/verification-code-email"
# # 绑定手机号发送验证码接口
# phone_verification_code_url = f"{ACCOUNT_HOST}{account_server}/api/user/verification-code"
# # 解绑手机号发送验证码接口
# unbind_phone_verification_code_url = f"{ACCOUNT_HOST}{account_server}/api/user/unbind/verification-code"
# # 绑定手机接口
# bind_mobile_phone_url = f"{ACCOUNT_HOST}{account_server}/api/user/bind-mobile-phone"
# # 解绑手机号接口
# unbind_mobile_phone_url = f"{ACCOUNT_HOST}{account_server}/api/user/unbind-mobile-phone"
# # 创建企业
# create_enterprise_url = f"{ACCOUNT_HOST}{account_server}/api/enterprise/create"
# # 企业列表
# list_enterprise_url = f"{ACCOUNT_HOST}{account_server}/api/enterprise/list"
# # 更新默认企业
# update_default_enterprise_url = f"{ACCOUNT_HOST}{account_server}/api/enterprise/update"
# # #修改用户状态接口
# # update_user_status_url=f"{ACCOUNT_HOST}{account_server}/api/user/update-status"
# # 查询用户详情
# get_userInfo_url = f"{ACCOUNT_HOST}{account_server}/oauth"
# # 根据令牌获取登录信息
# get_userInfo_by_ticket_url = f"{ACCOUNT_HOST}{account_server}/oauth/ticket"
# # 通过手机号找回密码
# forget_password_by_mobilePhone_url = f"{ACCOUNT_HOST}{account_server}/oauth/forget"
# # 通过邮箱找回密码
# forget_password_by_email_url = f"{ACCOUNT_HOST}{account_server}/oauth/forget/password/email"
# # 发送忘记密码验证码
# forget_verification_code_url = f"{ACCOUNT_HOST}{account_server}/oauth/forget/verification-code"
# # 忘记密码通过邮箱发送验证码
# forget_email_verification_code_url = f"{ACCOUNT_HOST}{account_server}/oauth/forget/verification-email-code"
# # 修改密码接口
# modify_password_url = f"{ACCOUNT_HOST}{account_server}/api/user/password/reset"
# # 重置密码
# reset_password_url = f"{ACCOUNT_HOST}{account_server}/oauth/reset"
# # 查询平台角色列表
# get_platform_role_url = f"{ACCOUNT_HOST}{account_server}/api/platform/platform-role-list"
# # 个人信息设置接口
# modify_user_info_url = f"{ACCOUNT_HOST}{account_server}/api/user/modify-user-info"
# # 编辑用户详情接口
# modify_user_detail_url = f"{ACCOUNT_HOST}{account_server}/api/user/modify-user-detail"
# # 设置个人信息时获取用户信息接口
# get_user_info_url = f"{ACCOUNT_HOST}{account_server}/api/user/get-user-info"
# # 查询用户详细信息接口-对外
# get_userdetail_url = f"{ACCOUNT_HOST}{account_server}/s/user/get-userdetail"
# # 批量查询用户-对外
# get_userdetail_list_url = f"{ACCOUNT_HOST}{account_server}/s/user/get-userdetail-list"
# # 移除用户接口
# remove_user_url = f"{ACCOUNT_HOST}{account_server}/api/user/remove-user"
# # 对内-邮件邀请
# invitation_email_url = f"{ACCOUNT_HOST}{account_server}/api/user/invitation/email/invitation"
# # 对外-邮件邀请
# open_invitation_email_url = f"{ACCOUNT_HOST}{account_server}/api/user/invitation/open/email/invitation"
# # 对外-激活邮件
# activate_email_url = f"{ACCOUNT_HOST}{account_server}/open/activate"
# # 产品授权信息列表查询接口
# platform_authorization_list_url = f"{ACCOUNT_HOST}{account_server}/api/user/platform-authorization-list"
# # 查询用户及企业信息接口-对外
# get_userinfo_enterprise_url = f"{ACCOUNT_HOST}{account_server}/api/user/get-userinfo-enterprise"
# # 企业logo上传
# upload_enterprise_logo_url = f"{ACCOUNT_HOST}{account_server}/api/enterprise/upload/logo"
# # 创建角色
# create_role_url = f"{ACCOUNT_HOST}{account_server}/api/role/role/create"
# # 分页查询企业下的用户
# get_enterprise_user_url = f"{ACCOUNT_HOST}{account_server}/api/user/get-enterprise-user-page"
# # 生成邀请编码
# create_link_url = f"{ACCOUNT_HOST}{account_server}/api/invitation-link/create-link"
# # 查询企业/空间层级
# enterprise_space_hierarchy_url = f"{ACCOUNT_HOST}{account_server}/api/space/enterprise-space-hierarchy"
# # 链接邀请加入企业空间
# join_invitation_link_url = f"{ACCOUNT_HOST}{account_server}/api/invitation-link/join"
# # 根据code批量查询企业列表
# enterpriseList_by_codes_url = f"{ACCOUNT_HOST}{account_server}/s/enterprise/list"
# # 根据用户组查询用户
# get_userlist_by_group_url = f"{ACCOUNT_HOST}{account_server}/s/user/group/get-user-list"
# # 根据用户id查询用户组
# get_grouplist_by_userId_url = f"{ACCOUNT_HOST}{account_server}/s/user/group/get-group-list"
# # 新增用户组
# # add_group_url = f"{ACCOUNT_HOST}{account_server}/api/user/group/add-group"
# add_group_url = f"{ACCOUNT_HOST}{account_server}/api/user/group/space/add-group"
# # 删除用户组
# # remove_group_url = f"{ACCOUNT_HOST}{account_server}/api/user/group/remove-group"
# remove_group_url = f"{ACCOUNT_HOST}{account_server}/api/user/group/remove-group-space"
# # 根据用户组查询用户(包括所有子集用户)
# get_all_children_user_list_url = f"{ACCOUNT_HOST}{account_server}/s/user/group/get-all-children-user-list"
# # 查询当前企业下所有用户组
# get_all_group_list_url = f"{ACCOUNT_HOST}{account_server}/s/user/group/get-all-group-list"
# # 校验邀请码并修改用户激活状态
# check_invitation_code_url = f"{ACCOUNT_HOST}{account_server}/api/user/invitation/check-invitation-code"
# # 导出用户接口
# export_user_url = f"{ACCOUNT_HOST}{account_server}/api/user/export"
# # 导出空间用户接口
# export_space_user_url = f"{ACCOUNT_HOST}{account_server}/api/user/export/space"
# # 导入用户接口
# import_user_url = f"{ACCOUNT_HOST}{account_server}/api/user/import"
# # 分页-查询用户信息列表接口（空间）
# user_space_page_url = f"{ACCOUNT_HOST}{account_server}/api/user/space/page"
# # 分页-查询用户信息列表接口
# user_page_url = f"{ACCOUNT_HOST}{account_server}/api/user/page"
# # 分页-查询用户组列表接口
# user_group_list_url = f"{ACCOUNT_HOST}{account_server}/api/user/group/user-group-list"
# # 查询用户组详情
# get_user_group_detail_url = f"{ACCOUNT_HOST}{account_server}/api/user/group/get-user-group-detail"
# # 空间-邮件邀请
# email_invitation_space_url = f"{ACCOUNT_HOST}{account_server}/api/user/invitation/space/email/invitation"
#

# class USER_ACCOUNT:
#     """用户中心相关接口"""
#
#     @staticmethod
#     def register(payload):
#         """注册接口"""
#         if payload.get('password'):
#             # 加密
#             payload['password'] = get_sha256(get_sha256(get_sha256(payload.get('password'))))
#         r = requests.post(url=register_url, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def register_verification_code(payload, getCode=False):
#         """发送注册验证码"""
#         r = requests.request("post", url=register_verification_code_url, params=payload, verify=False)
#         # 如果为true则返回验证码
#         if getCode:
#             mobilePhone = payload.get('mobilePhone')
#             code = RedisManager().get(f'REGISTER_CODE:{mobilePhone}')
#             return code
#         return r
#
#     @staticmethod
#     def login(payload, get_token=False, get_userId=False, get_cookies=False):
#         """登录接口"""
#         # 加密
#         payload['password'] = get_sha256(get_sha256(get_sha256(payload.get('password'))))
#         r = requests.post(url=login_url, json=payload, verify=False)
#         if get_token:
#             return r.json().get('data').get('token')
#         elif get_userId:
#             return r.json().get('data').get('userId')
#         elif get_cookies:
#             cookie = ''
#             for name, value in r.cookies.items():
#                 cookie += '{0}={1};'.format(name, value)
#             return cookie
#         else:
#             return r
#
#     @staticmethod
#     def login_ticket(payload, get_ticket=False):
#         """登录接口(临时令牌)"""
#         # 加密
#         payload['password'] = get_sha256(get_sha256(get_sha256(payload.get('password'))))
#         r = requests.post(url=login_ticket_url, json=payload, verify=False)
#         if get_ticket:
#             return r.json().get('data').get('ticket')
#         else:
#             return r
#
#     @staticmethod
#     def logout(header):
#         """登出接口"""
#         r = requests.post(url=logout_url, headers=header, verify=False)
#         return r
#
#     @staticmethod
#     def login_verification_code(payload, getCode=False):
#         """发送登录验证码"""
#         r = requests.request("post", url=login_verification_code_url, params=payload, verify=False)
#         # 如果为true则返回验证码
#         if getCode and r.json().get('status'):
#             mobilePhone = payload.get('mobilePhone')
#             code = RedisManager().get(f'LOGIN_VERIFICATION_CODE:{mobilePhone}')
#             return code
#         return r
#
#     @staticmethod
#     def login_by_code(payload):
#         """验证码登录"""
#         r = requests.post(url=login_by_code_url, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def ticket_login_by_code(payload):
#         """验证码登录(临时令牌)"""
#         r = requests.post(url=ticket_login_by_code_url, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def bind_email(payload, header):
#         """绑定邮箱"""
#         r = requests.request('post', url=bind_email_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def unbind_email(payload, header):
#         """解绑邮箱"""
#         r = requests.request('post', url=unbind_email_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def email_verification_code(payload, header, getCode=False):
#         """绑定邮箱发送邮件验证码接口"""
#         r = requests.get(url=email_verification_code_url, headers=header, params=payload, verify=False)
#         if getCode and r.json().get('status'):
#             email = payload.get('email')
#             code = RedisManager().get(f'BIND_EMAIL_CODE:{email}')
#             return code
#         return r
#
#     @staticmethod
#     def unbind_email_verification_code(payload, header, getCode=False):
#         """解绑邮箱发送邮件验证码接口"""
#         r = requests.get(url=unbind_email_verification_code_url, headers=header, params=payload, verify=False)
#         if getCode and r.json().get('status'):
#             email = payload.get('email')
#             code = RedisManager().get(f'UNBIND_EMAIL_CODE:{email}')
#             return code
#         return r
#
#     @staticmethod
#     def phone_verification_code(payload, header, getCode=False):
#         """绑定手机号发送验证码"""
#         r = requests.get(url=phone_verification_code_url, headers=header, params=payload, verify=False)
#         if getCode and r.json().get('status'):
#             mobilePhone = payload.get('mobilePhone')
#             code = RedisManager().get(f'BIND_MOBILEPHONE_CODE:{mobilePhone}')
#             return code
#         return r
#
#     @staticmethod
#     def unbind_phone_verification_code(payload, header, getCode=False):
#         """解绑手机号发送验证码"""
#         r = requests.get(url=unbind_phone_verification_code_url, headers=header, params=payload, verify=False)
#         if getCode:
#             mobilePhone = payload.get('mobilePhone')
#             code = RedisManager().get(f'UNBIND_MOBILEPHONE_CODE:{mobilePhone}')
#             return code
#         return r
#
#     @staticmethod
#     def bind_mobile_phone(payload, header):
#         """绑定手机"""
#         r = requests.request("post", url=bind_mobile_phone_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def unbind_mobile_phone(payload, header):
#         """解绑手机"""
#         r = requests.request("post", url=unbind_mobile_phone_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def create_enterprise(payload, header):
#         """创建企业"""
#         r = requests.post(url=create_enterprise_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def list_enterprise(header):
#         """查询企业列表"""
#         r = requests.get(url=list_enterprise_url, headers=header, verify=False)
#         return r
#
#     @staticmethod
#     def update_default_enterprise(payload, header):
#         """根据企业id更新默认企业"""
#         r = requests.request("post", url=update_default_enterprise_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def get_userInfo(token):
#         """查询用户详情"""
#         r = requests.get(url=get_userInfo_url, params={"token": token}, verify=False)
#         return r
#
#     @staticmethod
#     def get_userInfo_by_ticket(ticket):
#         """查询用户详情"""
#         r = requests.get(url=get_userInfo_by_ticket_url, params={"ticket": ticket}, verify=False)
#         return r
#
#     @staticmethod
#     def forget_password_by_mobilePhone(payload):
#         """忘记密码通过手机号找回密码"""
#         if payload.get('password'):
#             # 加密
#             payload['password'] = get_sha256(get_sha256(get_sha256(payload.get('password'))))
#         r = requests.post(url=forget_password_by_mobilePhone_url, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def forget_password_by_email(payload):
#         """忘记密码通过邮箱找回密码"""
#         if payload.get('password'):
#             # 加密
#             payload['password'] = get_sha256(get_sha256(get_sha256(payload.get('password'))))
#         r = requests.post(url=forget_password_by_email_url, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def forget_verification_code(payload, getCode=False):
#         """发送忘记密码验证码"""
#         r = requests.request("post", url=forget_verification_code_url, params=payload, verify=False)
#         if getCode and r.json().get('status'):
#             mobilePhone = payload.get('mobilePhone')
#             code = RedisManager().get(f'FORGET_PASSWORD_CODE:{mobilePhone}')
#             return code
#         return r
#
#     @staticmethod
#     def forget_email_verification_code(payload, getCode=False):
#         """忘记密码通过邮箱发送验证码"""
#         r = requests.request("post", url=forget_email_verification_code_url, params=payload, verify=False)
#         if getCode and r.json().get('status'):
#             mobilePhone = payload.get('mobilePhone')
#             code = RedisManager().get(f'FORGET_PASSWORD_CODE_EMAIL:{mobilePhone}')
#             return code
#         return r
#
#     @staticmethod
#     def reset_password(payload):
#         """重置密码"""
#         if payload.get('password'):
#             # 加密
#             payload['password'] = get_sha256(get_sha256(get_sha256(payload.get('password'))))
#         r = requests.post(url=reset_password_url, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def modify_password(payload, header):
#         """修改密码"""
#         if payload.get('newPassword'):
#             # 加密
#             payload['newPassword'] = get_sha256(get_sha256(get_sha256(payload.get('newPassword'))))
#         if payload.get('password'):
#             # 加密
#             payload['password'] = get_sha256(get_sha256(get_sha256(payload.get('password'))))
#         r = requests.request("post", url=modify_password_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def get_platform_role(payload, header):
#         """查询平台角色列表"""
#         r = requests.get(url=get_platform_role_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def get_user_info(header):
#         """设置个人信息时获取用户信息接口"""
#         r = requests.get(url=get_user_info_url, headers=header, verify=False)
#         return r
#
#     @staticmethod
#     def get_userdetail(payload, header):
#         """查询用户详细信息接口-对外"""
#         r = requests.get(url=get_userdetail_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def get_userdetail_list(payload, header):
#         """批量查询用户-对外"""
#         r = requests.post(url=get_userdetail_list_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def remove_user(payload, header):
#         """移除用户"""
#         r = requests.post(url=remove_user_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def invitation_email(payload, header):
#         """发送邮件邀请用户注册，并加入平台，加入企业-对内"""
#         r = requests.post(url=invitation_email_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def open_invitation_email(payload, header):
#         """发送邮件邀请用户注册，并加入平台，加入企业-对外"""
#         r = requests.post(url=open_invitation_email_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def activate_email(payload):
#         """激活邮件中的链接点击后激活用户，成功后重定向至登录页面"""
#         r = requests.get(url=activate_email_url, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def modify_user_info(payload, header):
#         """个人信息设置"""
#         r = requests.request("post", url=modify_user_info_url, headers=header, data=payload, verify=False)
#         return r
#
#     @staticmethod
#     def modify_user_detail(payload, header):
#         """编辑用户详情"""
#         r = requests.request("post", url=modify_user_detail_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def platform_authorization_list(payload, header):
#         """产品授权信息列表查询"""
#         r = requests.request("post", url=platform_authorization_list_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def get_userinfo_enterprise(payload, header):
#         """查询用户及企业信息接口"""
#         r = requests.get(url=get_userinfo_enterprise_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def upload_enterprise_logo(filePath, header):
#         """企业logo上传"""
#         file = {'file': open(filePath, 'rb')}
#         r = requests.post(url=upload_enterprise_logo_url, headers=header, files=file, timeout=30, verify=False)
#         return r
#
#     @staticmethod
#     def checkCookie(cookie):
#         """cookie校验"""
#         header = {"cookie": cookie}
#         r = requests.get(url=checkCookie_url, headers=header, verify=False)
#         return r
#
#     @staticmethod
#     def create_role(payload, header):
#         """创建角色"""
#         r = requests.post(url=create_role_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def get_enterprise_user(payload, header):
#         """分页查询企业下的用户"""
#         r = requests.get(url=get_enterprise_user_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def create_link(payload, header):
#         """生成邀请编码"""
#         r = requests.get(url=create_link_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def enterprise_space_hierarchy(header, spaceID=None):
#         """
#         查询企业/空间层级
#         :param header: 请求头
#         :param spaceID: 空间id
#         :return: 如果传空间id的话则返回platformCode,spaceName
#         """
#         r = requests.get(url=enterprise_space_hierarchy_url, headers=header, verify=False)
#         if spaceID:
#             space_data = r.json().get('data')
#             for info in space_data:
#                 if info.get('spaceId') == spaceID:
#                     platformCode = info.get('platformCode')
#                     spaceName = info.get('spaceName')
#                     return platformCode, spaceName
#         return r
#
#     @staticmethod
#     def join_invitation_link(invitationCode, header=None):
#         """链接邀请加入企业空间"""
#         payload = {"invitationCode": invitationCode}
#         r = requests.get(url=join_invitation_link_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def enterpriseList_by_codes(payload, header):
#         """根据code批量查询企业列表"""
#         r = requests.post(url=enterpriseList_by_codes_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def remove_group(payload, header):
#         """删除用户组"""
#         r = requests.post(url=remove_group_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def get_all_children_user_list(payload, header):
#         """根据用户组查询用户(包括所有子集用户)"""
#         r = requests.get(url=get_all_children_user_list_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def get_all_group_list(enterpriseCode, header):
#         """查询当前企业下所有用户组"""
#         payload = {"enterpriseCode": enterpriseCode}
#         r = requests.get(url=get_all_group_list_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def get_userlist_by_group(payload, header):
#         """根据用户组查询用户"""
#         r = requests.get(url=get_userlist_by_group_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def get_grouplist_by_userId(payload, header):
#         """根据用户id查询用户组"""
#         r = requests.get(url=get_grouplist_by_userId_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def check_invitation_code(code, header):
#         """校验邀请码并修改用户激活状态"""
#         payload = {"code": code}
#         r = requests.get(url=check_invitation_code_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def export_user(header, payload=None):
#         """导出用户接口"""
#         r = requests.get(url=export_user_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def export_space_user(header, payload=None):
#         """导出空间用户接口"""
#         r = requests.get(url=export_space_user_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def import_user(payload, header, filePath):
#         """导入用户接口"""
#         file = {'file': open(filePath, 'rb')}
#         r = requests.post(url=import_user_url, headers=header, files=file, data=payload, verify=False)
#         return r
#
#     @staticmethod
#     def user_space_page(payload, header):
#         """分页-查询用户信息列表接口（空间）"""
#         r = requests.post(url=user_space_page_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def user_page(payload, header):
#         """分页-查询用户信息列表接口"""
#         r = requests.post(url=user_page_url, headers=header, json=payload, verify=False)
#         print(r.text)
#         return r
#
#     @staticmethod
#     def user_group_list(payload, header):
#         """分页-查询用户组列表接口"""
#         r = requests.post(url=user_group_list_url, headers=header, json=payload, verify=False)
#         return r
#
#     @staticmethod
#     def get_user_group_detail(payload, header):
#         """查询用户组详情"""
#         r = requests.get(url=get_user_group_detail_url, headers=header, params=payload, verify=False)
#         return r
#
#     @staticmethod
#     def email_invitation_space(payload, header):
#         """空间-邮件邀请"""
#         r = requests.post(url=email_invitation_space_url, headers=header, json=payload, verify=False)
#         return r
#
#     def invite_user_join_enterprise(self, userName, passWord, enterprise_code, invite_header):
#         """
#         邀请用户加入企业
#         :param userName:用户名
#         :param passWord:密码
#         :param enterprise_code:企业code
#         :param invite_header: 被邀请人的请求头
#         """
#         header = USER.get_header(userName, passWord, enterprise_code=enterprise_code)
#         # 生成邀请码
#         invitationCode = USER_ACCOUNT.create_link({"platformCode": "", "spaceId": ""}, header).json().get('data').get(
#             'invitationCode')
#         # 加入企业
#         USER_ACCOUNT.join_invitation_link(invitationCode, invite_header)


if __name__ == '__main__':
    pass
    from application.general_create import COOKIE, APP_ID, SPACE_ID, ENTERPRISE_ID

    headers = {"cookie": COOKIE, "language": "zh-cn", "app": APP_ID, "space": SPACE_ID, "enterprise-id": ENTERPRISE_ID}
    re = UserAccount(headers).create_user_join_enterprise_and_space(["122222@qq.com"], SPACE_ID, ENTERPRISE_ID)
    print(re)
